﻿//jquery实现对webservice的调用
function WebService(url, callback, pars) {
    $.ajax({
        data: pars,
        url: url,
        type: "POST",
        contentType: "application/json;utf-8",
        dataType: 'json',
        cache: false,
        success: function (json) {
            if (callback != null) {
                callback(json.d);
            }
        },
        error: function (xml, status) {
            if (status == 'error' || status == "parsererror") {
                try {
                    //var json = eval('(' + xml.responseText + ')');
                    //alert(json.Message + '\n' + json.StackTrace);
                    //alert(xml.responseText);
                } catch (e) { }
            } 
            else if(status != "") {
                    alert(status);
            }            
        },
        beforeSend: function (xml) {
            if (!pars) xml.setRequestHeader("Content-Type", "application/json;utf-8")
        }
    });
}